<?
class Kalenderwoche
{
	private $wochen_shift=0;

	public function setShift($shift)
	{
		// shift is expected in UNIX-Timestamp
		$shift *= 60 * 60 * 24 * 7;
		$this->wochen_shift=$shift;
	}

	public function resetShift()
	{
		$this->wochen_shift=0;
	}

	public function getShift()
	{
		return $this->wochen_shift/(60*60*24*7);
	}

	public function WochenTag()
	{
		$result = date('d.m.Y', time()+ $this->wochen_shift);
		return $result;
	}

	public function Tag()
	{
		$result = date('d', time()+ $this->wochen_shift);
		return $result;
	}

	public function Monat()
	{
		$result = date('m', time()+ $this->wochen_shift);
		return $result;
	}

	public function MonatsName()
	{
		$result = date('M', time()+ $this->wochen_shift);
		return $result;
	}

	public function Jahr()
	{
		$result = date('Y', time()+ $this->wochen_shift);
		return $result;
	}

	public function Wochenanfang()
	{
		if (date('w', time()) != 0)
			$wochenanfang = time() - (60 * 60 * 24 * (date('w', time())-1));
		else
			$wochenanfang = time() - (60 * 60 * 24 * (date('w', time())+6));

		$wochenanfang = date('d.m.Y', $wochenanfang + $this->wochen_shift);
		return $wochenanfang;
	}

	public function Wochenende()
	{
		if (date('w', time()) != 0)
			$wochenende = time() + (60 * 60 * 24 * (7-date('w', time())));
		else
			$wochenende = time();
		
		$wochenende = date('d.m.Y', $wochenende + $this->wochen_shift);
		return $wochenende;
	}

	public function KWoche()
	{
		$kalenderwoche = date('W', time() + $this->wochen_shift);
		return $kalenderwoche;
	}

	public function usDate2gerDate($date)
	{
		$tmp = date_create($date);
		$result = date_format($tmp, "d.m.Y");
		return $result;
	}

	public function gerDate2usDate($date)
	{
		$tmp = date_create($date);
		$result = date_format($tmp, "Y-m-d");
		return $result;
	}
}
?>
